package person.bing.fbcloud.leetcode;

/**
 * @author: mengfanbing
 * @date: 2020/8/20 16:23
 */
public class Q27 {
    public static void main(String[] args) {
        int[] nums = {0,1,2,2,3,0,4,2};
        int val = 2;
        int ans = removeElement(nums, val);
        System.out.println(ans);
    }

    public static int removeElement(int[] nums, int val) {
        int ans = 0;
        for (int j=0;j<nums.length;j++){
            if (nums[j] != val){
                nums[ans] = nums[j];
                ans++;
            }
        }
        return ans;
    }
}
